<?xml version="1.0"?>
<atom:feed xmlns:atom="http://www.w3.org/2005/Atom" xmlns:html="http://www.w3.org/1999/xhtml">
  <atom:id>http://caudium.net/atom/documentation/PHP Setup</atom:id>
  <atom:title type="text">Caudium :: PHP Setup</atom:title>
  <atom:updated>2026-04-11T03:00:44-04:00</atom:updated>
  <atom:link href="http://caudium.net/atom/documentation/PHP Setup" type="application/atom+xml"></atom:link>
  <atom:link href="http://caudium.net/space/documentation/PHP Setup" type="text/html"></atom:link>
  <atom:link href="http://caudium.net/rss/documentation/PHP Setup" type="application/rss+xml"></atom:link>
  <atom:generator uri="http://modules.gotpike.org/blahblah/Public.Syndication.ATOM" version="0.1">Public.Syndication.ATOM (Pike v8.0 release 702)</atom:generator>
  <atom:icon>http://caudium.net/favicon.ico</atom:icon>
  <atom:logo>http://caudium.net/caudium.png</atom:logo>
  <atom:subtitle type="xhtml"><html:div xmlns:html="http://www.w3.org/1999/xhtml"><html:h2>&#xD;
1. Introduction&#xA0;&#xD;
</html:h2>&#xD;
There are two recommended ways to run PHP with Caudium. Each way has its advantages and drawbacks.&#xD;
<html:br/>&#xD;
<html:br/>&#xD;
PHP can be run:&#xA0;&#xD;
<html:br/>&#xD;
<html:ul>&#xD;
	<html:li style="min-height: 1.2em;">&#xD;
		As a CGI, using Caudium Uniscript module.&#xD;
	</html:li>&#xD;
	<html:li style="min-height: 1.2em;">&#xD;
		As a FastCGI, using Caudium FastUniscript module.&#xD;
	</html:li>&#xD;
</html:ul>&#xD;
<html:br/>&#xD;
Both methods are similar, simply compile your PHP with support for FastCGI to use the second option and replace FastUniscript in the instructions.&#xA0; A third method using PHP as a module is&#xA0;not supported anymore&#xA0;due to PHP bugs. Read further for more information&#xD;
<html:br/>&#xD;
<html:br/>&#xD;
<html:h2>&#xD;
2. PHP using Uniscript&#xD;
</html:h2>&#xD;
<html:h3>&#xD;
2.1. Introduction to Uniscript Mode&#xD;
</html:h3>&#xD;
<html:br/>&#xD;
Uniscript mode is in fact using PHP in CGI mode. Caudium has a module named&#xA0;Universal Script Parser&#xA0;that allows you to wrap any special extensions inside a webserver to a&#xA0;CGI. Eg&#xA0;.php&#xA0;to&#xA0;/usr/local/bin/php. This is the way PHP will be run.&#xD;
<html:br/>&#xD;
<html:br/>&#xD;
<html:h3>&#xD;
2.2. Drawbacks&#xD;
</html:h3>&#xD;
<html:ul>&#xD;
	<html:li>&#xD;
		A PHP interpreter is forked on each page called. This can be ressource consuming.&#xD;
	</html:li>&#xD;
	<html:li>&#xD;
		Some PHP options and some security options must be considered. See the&#xA0;PHP manual&#xA0;about PHP install as a CGI manual.&#xD;
	</html:li>&#xD;
</html:ul>&#xD;
<html:h3>&#xD;
2.3. Benefits&#xD;
</html:h3>&#xD;
<html:ul>&#xD;
	<html:li>&#xD;
		Since it is in a CGI, when PHP crashes Caudium doesn't :).&#xD;
	</html:li>&#xD;
	<html:li>&#xD;
		You can run PHP as a user different than Caudium.&#xD;
	</html:li>&#xD;
	<html:li>&#xD;
		You can give specify limitation on the size of processes and resources usage.&#xD;
	</html:li>&#xD;
	<html:li>&#xD;
		You can have several PHP interpreters with different&#xA0;php.ini&#xA0;files and compilations.&#xD;
	</html:li>&#xD;
</html:ul>&#xD;
<html:h3>&#xD;
2.4. Software requirements&#xD;
</html:h3>&#xD;
Before installing PHP4 support as a CGI for Caudium, you will need the following:&#xD;
<html:ul>&#xD;
	<html:li>&#xD;
		An OS supported by PHP4 and Caudium.&#xD;
	</html:li>&#xD;
	<html:li>&#xD;
		Caudium installed (you&#xA0;don't&#xA0;need Pike development headers).&#xD;
	</html:li>&#xD;
	<html:li>&#xD;
		PHP4 sources (we recommend PHP 4.3.2RC2)&#xD;
	</html:li>&#xD;
	<html:li>&#xD;
		An ANSI C compiler and all libraries needed for compiling PHP.&#xD;
	</html:li>&#xD;
</html:ul>&#xD;
<html:br/>&#xD;
We assume that you have successfully installed Pike and Caudium on your machine.&#xD;
<html:br/>&#xD;
<html:br/>&#xD;
<html:h3>&#xD;
2.5. Compilation and installation of PHP&#xD;
</html:h3>&#xD;
<html:br/>&#xD;
NOTE: in this example, we assume that we will install all PHP in&#xA0;/usr/local/php-4.3.2RC-cgi/.&#xD;
<html:br/>&#xD;
Extract PHP4 source somewhere and do the following :&#xD;
<html:br/>&#xD;
<html:br/>&#xD;
&#xA0;&#xD;
<html:div class="code"><html:pre><html:pre>&#xD;
 $ cd php-4.3.2RC2&#xD;
 $ ./configure --prefix=/usr/local/php-4.3.2RC-cgi/ --enable-force-cgi-redirect \&#xD;
               --enable-discard-path --enable-fastcgi --without-pear --enable-safe-mode \&#xD;
               --enable-sigchild --enable-magic-quotes --disable-rpath \&#xD;
               --with-other-php-options&#xD;
 $ make&#xD;
</html:pre></html:pre></html:div>
&#xD;
Now the PHP interpreter is fully compiled and can be installed.&#xD;
<html:br/>&#xD;
&#xD;
	<html:br/>&#xD;
<html:div class="code"><html:pre><html:pre>&#xD;
 $ make install&#xD;
</html:pre></html:pre></html:div>
&#xD;
	<html:br/>&#xD;
	<html:br/>&#xD;
<html:h3>&#xD;
2.6. Configuring Caudium&#xD;
</html:h3>&#xD;
Log into the graphical configuration interface and go to the virtual server where you want to add PHP support.&#xA0;&#xA0;&#xD;
<html:br/>&#xD;
<html:br/>&#xD;
Click on "Add Module", locate and add PATH_INFO support module and Universal Script parser module.&#xA0;&#xD;
<html:br/>&#xD;
<html:br/>&#xD;
Then configure the Universal Script Parser module with the following options :&#xD;
<html:br/>&#xD;
<html:br/>&#xD;
<html:ul>&#xD;
	<html:li>&#xD;
		interpreter path :&#xA0;/usr/local/php-4.3.2RC-cgi/bin/php&#xA0;or the place where where you have installed php. &#xA0;&#xD;
	</html:li>&#xD;
	<html:li>&#xD;
		script extensions :&#xA0;php&#xA0;or comma separated extensions you'd like to handle with that php cgi. &#xA0;&#xD;
	</html:li>&#xD;
</html:ul>&#xD;
<html:br/>&#xD;
Note that you can configure the&#xA0;<html:i>Run script as</html:i>&#xA0;option if you want to run php with a different user than default:nobody.&#xA0;&#xD;
<html:br/>&#xD;
<html:br/>&#xD;
Then create a test page with :&#xD;
<html:br/>&#xD;
<html:br/>&#xD;
<html:div class="code"><html:pre><html:pre>&#xD;
&lt;? phpinfo(); ?&gt;&#xD;
</html:pre></html:pre></html:div>
&#xD;
<html:br/>&#xD;
&#xA0;&#xA0;&#xD;
<html:br/>&#xD;
Then you will get the PHP Info page.&#xD;
<html:br/>&#xD;
<html:br/>&#xD;
<html:h3>&#xD;
2.7. Hints&#xD;
</html:h3>&#xD;
To use sessions in CGI mode you will need to save them on disk instead of memory. To do that, you will need to change/add option in you&#xA0;/usr/local/php-4.3.2RC-cgi/lib/php.ini:&#xD;
<html:br/>&#xD;
&#xA0;&#xD;
<html:div class="code"><html:pre><html:pre>&#xD;
[Session]&#xD;
; Handler used to store/retrieve data.&#xD;
session.save_handler = files&#xD;
&#xD;
; Argument passed to save_handler.  In the <html:font color="black">case</html:font> of files, this is the path&#xD;
; where data files are stored. Note<html:font color="black">:</html:font> Windows users have to change this &#xD;
; variable in order to use PHP's session <html:b><html:font color="darkgreen">function</html:font></html:b><html:b><html:font color="darkbrown">s.</html:font></html:b>&#xD;
; As of PHP 4.0.1, you can define the path as:&#xD;
;     session.save_path = <html:i><html:font color="darkred">"N;/path"</html:font></html:i>&#xD;
; where N is an <html:b><html:font color="darkgreen">int</html:font></html:b><html:b><html:font color="darkbrown">eger.</html:font></html:b>  Instead of storing all the session files in &#xD;
; /path, what this will <html:b><html:font color="darkblue">do</html:font></html:b> is use subdirectories N-levels deep, and &#xD;
; store the session data in those directories.  This is useful <html:b><html:font color="darkblue">if</html:font></html:b> you &#xD;
; or your OS have problems with lots of files in one directory, and is &#xD;
; a more efficient layout <html:b><html:font color="darkblue">for</html:font></html:b> servers that handle lots of sessions.&#xD;
; NOTE 1: PHP will not create this directory structure automatically.&#xD;
;         You can use the script in the ext/session dir <html:b><html:font color="darkblue">for</html:font></html:b> that purpose.&#xD;
; NOTE 2: See the section on garbage collection below <html:b><html:font color="darkblue">if</html:font></html:b> you choose to&#xD;
;         use subdirectories <html:b><html:font color="darkblue">for</html:font></html:b> session storage&#xD;
session.save_path = /var/sessions&#xD;
&#xD;
; Whether to use cookies.&#xD;
session.use_cookies = 1&#xD;
&#xD;
; This option enables administrators to make their users invulnerable to&#xD;
; attacks which involve passing session ids in URLs; defaults to 0.&#xD;
; session.use_only_cookies = 1&#xD;
&#xD;
; Name of the session (used as cookie name).&#xD;
session.name = PHPSESSID&#xD;
&#xD;
; Initialize session on request startup.&#xD;
session.auto_start = 0&#xD;
&#xD;
; Lifetime in seconds of cookie or, if 0, until browser is restarted.&#xD;
session.cookie_lifetime = 0&#xD;
&#xD;
; The path <html:b><html:font color="darkblue">for</html:font></html:b> which the cookie is valid.&#xD;
session.cookie_path = /&#xD;
&#xD;
; The domain <html:b><html:font color="darkblue">for</html:font></html:b> which the cookie is valid.&#xD;
session.cookie_domain =&#xD;
&#xD;
; Handler used to serialize data.  php is the standard serializer of PHP.&#xD;
session.serialize_handler = php&#xD;
&#xD;
; Define the probability that the 'garbage collection' process is started&#xD;
; on every session initialization.&#xD;
; The probability is calculated by using gc_probability/gc_divisor,&#xD;
; e.g. 1/100 means there is a 1% chance that the GC process starts&#xD;
; on each request.&#xD;
&#xD;
session.gc_probability = 1&#xD;
session.gc_divisor     = 100&#xD;
&#xD;
; After this number of seconds, stored data will be seen as 'garbage' and&#xD;
; cleaned up by the garbage collection process.&#xD;
session.gc_maxlifetime = 1440&#xD;
&#xD;
; NOTE: If you are using the subdirectory option <html:b><html:font color="darkblue">for</html:font></html:b> storing session files&#xD;
;       (see session.save_path above), then garbage collection does *not*&#xD;
;       happen automatically.  You will need to do your own garbage &#xD;
;       collection through a shell script, cron entry, or some other method. &#xD;
;       For example, the following script would is the equivalent of&#xD;
;       setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):&#xD;
;          cd /path/to/sessions; find -cmin +24 | xargs rm&#xD;
; PHP 4.2 and less have an undocumented feature/bug that allows you to&#xD;
; to initialize a session variable in the global scope, albeit register_globals&#xD;
; is disabled.  PHP 4.3 and later will warn you, if this feature is used.&#xD;
; You can disable the feature and the warning seperately. At this time,&#xD;
; the warning is only displayed, if bug_compat_42 is enabled.&#xD;
&#xD;
session.bug_compat_42 = 1&#xD;
session.bug_compat_warn = 1&#xD;
&#xD;
; Check HTTP Referer to invalidate externally stored URLs containing ids.&#xD;
; HTTP_REFERER has to contain this substring <html:b><html:font color="darkblue">for</html:font></html:b> the session to be&#xD;
; considered as valid.&#xD;
session.referer_check =&#xD;
&#xD;
; How many bytes to read from the file.&#xD;
session.entropy_length = 12&#xD;
&#xD;
; Specified here to create the session id.&#xD;
session.entropy_file = /dev/urandom&#xD;
&#xD;
;session.entropy_length = 16&#xD;
&#xD;
;session.entropy_file = /dev/urandom&#xD;
; Set to {nocache,private,public,} to determine HTTP caching aspects&#xD;
; or leave this empty to avoid sending anti-caching headers.&#xD;
session.cache_limiter = nocache&#xD;
&#xD;
; Document expires after n minutes.&#xD;
session.cache_expire = 180&#xD;
&#xD;
; trans sid support is disabled by default.&#xD;
; Use of trans sid may risk your users security. &#xD;
; Use this option with caution.&#xD;
; - User may send URL contains active session ID&#xD;
;   to other person via. email/irc/etc.&#xD;
; - URL that contains active session ID may be stored&#xD;
;   in publically accessible computer.&#xD;
; - User may access your site with the same session ID&#xD;
;   always using URL stored in browser's history or bookmarks.&#xD;
session.use_trans_sid = 0&#xD;
</html:pre></html:pre></html:div>
&#xD;
<html:p>&#xD;
&#xD;
Please check your PHP manual for more information about this parameters.&#xD;
<html:br/>&#xD;
<html:br/>&#xD;
</html:p><html:h2>&#xD;
3. PHP as a module (not supported anymore)&#xD;
</html:h2>&#xD;
Some documentation (eg the one from&#xA0;PHP) may give some instructions for building and using PHP as a module. &#xA0; However, embedded PHP does not work well in a threaded environment. It neither work on Apache 2.0 and this won't be fixed in the forseeable future (a few years at least&#xA0;according to Rasmus LERDORF) &#xA0;  While this may behave correctly while running Caudium unthreaded, this usage is not supported by the Caudium group anymore and won't be until this issue is not fixed on the&#xA0;PHP side.&#xD;
<html:br/>&#xD;
<html:br/>&#xD;
Please use the CGI/FastCGI modes instead.&#xA0;&#xD;
<html:br/>&#xD;
<html:br/>&#xD;
<html:h2>&#xD;
4. Conclusion&#xD;
</html:h2>&#xD;
At the time of writing this document, the most stable way to use PHP is the CGI one. &#xA0;It is up to you to decide between stability and speed. But the difference between them is not so big, only stability may be an issue.&#xD;
</html:div></atom:subtitle>
</atom:feed>
